// Author: Domien Nowicki, Bjorn Schobben

#ifndef TEXTUREMANAGERVIEW_H
#define TEXTUREMANAGERVIEW_H

#include <QListView>
#include <QContextMenuEvent>
#include <QAction>
#include "TextureManagerModel.h"
#include "TextureItemDelegate.h"
#include "Pixel.h"



class TextureManagerView : public QListView
{
	Q_OBJECT

	public:
		TextureManagerView(QWidget *parent = 0);
		virtual ~TextureManagerView();

		unsigned int GetTextureCount() const;
		const Texture& GetTexture(unsigned int tindex) const;
		const QPixmap& GetTextureThumb(unsigned int tindex) const;
		unsigned int GetCurrentTextureIndex() const;
		
		unsigned int AddTexture(const Texture& texture);
		void RemoveTexture(unsigned int index);

		void SetModel(TextureManagerModel *texModel);
		TextureManagerModel* GetModel() const;
	protected:
		QSize sizeHint() const;
		QSize minimumSizeHint() const;
		QSize maximumSizeHint() const;
		void contextMenuEvent(QContextMenuEvent *e);

	signals:
		void changeUserColor(unsigned int tindex, const Pixel& userColor);
		void selectTexture();
		void removeTexture();
		void addSolidTexture();
	private slots:
		void slotColor();
		void slotSelect();
		void slotRemove();
		void slotAddSolid();

	private:
		QAction *colorAction, *selectAction, *removeAction, *addSolidAction;
		TextureManagerModel *textureModel;

		static const unsigned int THUMBSIZE = 64;
};	


#endif // TEXTUREMANAGERVIEW_H


